package com.hncj.yqfk.service.impl;

import com.hncj.yqfk.ldao.USER_Dao;
import com.hncj.yqfk.entity.USER;
import com.hncj.yqfk.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImp implements UserService {
    @Resource
    private  USER_Dao ud;

    @Override
    public USER findUserByUsernameAndPassword(String username, String password) {
//        List<USER> ud1= (List<USER>) ud.findUserByUsernameAndPassword(username, password);
        List<USER> ud1= ud.findUserByUsernameAndPassword(username, password);
        if (ud1.size()>0){
            return ud1.get(0);
        }
        return null;
    }
    @Override
    public boolean addUser(USER u) {
        return ud.save(u)!=null;
    }

    public List<USER> findByName(String username) {
        return ud.findByUsername(username);
    }
}
